import React, { Component } from 'react'
import { View, StyleSheet, Text, WebView, requireNativeComponent ,DeviceEventEmitter,NativeModules} from 'react-native'
import PropTypes from 'prop-types'
import AndroidWebView from '../../components/AndroidWebView'


export default class HomePage extends Component {

    constructor(props) {
        super(props)
        this.logoutlistener =  DeviceEventEmitter.addListener('LOGOUT', this._logout)
    }
    
    render() {
        return <AndroidWebView
            para={{
                url: "http://121.18.229.58:20001/liveapp/homepage",
                domain: "121.18.229.58"
            }}
            style={styles.container}
        />
    }
    _loadSuccess = () => {
        console.log('加载成功')
    }
    _loadEnd = () => {
        console.log('加载完成')
    }
    _loadError = () => {
        console.log('加载失败')
    }

    _logout = () => {
        this.props.navigation.navigate('login')
        this.logoutlistener.remove()
    }

    componentWillUnmount(){
        this.logoutlistener.remove()
     }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        // backgroundColor: 'green'
    }
})
